package com.endoc.designpattern.entity.fruit;

import com.endoc.designpattern.entity.Fruit;
import com.endoc.designpattern.visit.Visit;

public class Apple  implements Fruit {
    public void setPrice(int price) {
        this.price = price;
    }

    int price;

    public Apple(int price) {
        this.price = price;
    }

    @Override
    public int price() {
        return price;
    }

    @Override
    public String name() {
        return "苹果";
    }

    @Override
    public void setVisit(Visit visit) {
        visit.sell(this);//访问者模式,传入this,可实例化真实对象
        //System.out.println("调用了"+name());
    }
}
